package com.dys.controller;

import com.dys.service.AdminService;
import com.dys.util.Admin;
import com.dys.util.Cp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @RequestMapping("/adminLogin")
    public String adminLogin(Admin admin, HttpSession session, Model model) {
        Admin a = adminService.adminLogin(admin);
        session.setAttribute("admin", a);
        List<Cp> list = adminService.getAllCp();
        model.addAttribute("list",list);
        return "redirect:/cp/getAllCp.do";

    }


}